<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link href="starter-template.css" rel="stylesheet">
    <link href="input-upload.css" rel="stylesheet" />


    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false"
                    aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">Project name</a>
            </div>
            <div id="navbar" class="collapse navbar-collapse">
                <ul class="nav navbar-nav">
                    <li class="active">
                        <a href="#">Home</a>
                    </li>
                    <li>
                        <a href="#about">About</a>
                    </li>
                    <li>
                        <a href="#contact">Contact</a>
                    </li>
                </ul>
            </div>
            <!--/.nav-collapse -->
        </div>
    </nav>

    <div class="container">

        <div class="starter-template">
            <h1>Bootstrap starter template</h1>
            <p class="lead">Use this document as a way to quickly start any new project.
                <br> All you get is this text and a mostly barebones HTML document.</p>
        </div>
        <div id="input">
            <div class="aaa">
                <form method="post" action="/uploadServlet" enctype="multipart/form-data">
                    <div id="box">
                        <input type="text" id="file_name" readonly="readonly" value="未选择文件" />
                        <a href="javascript:void(0);" class="input">
                            浏览
                            <input type="file" id="file" name="document[file]">
                        </a>
                        <a href="javascript:void(0);" class="input">
                            上传
                            <input type="submit" name="sudmit" id="submit" value="上传" />
                        </a>
                        <br>
                        <br>
                        <br>
                        <div id="t_box">
                            <span id="t">值得信任的内容托管系统-8%的可靠和累积23小时的无障碍运行性</span>
                        </div>

                    </div>
                </form>
            </div>
        </div>

    </div>
    <!-- /.container -->

    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#file").change(function () { // 当 id 为 file 的对象发生变化时
                var fileSize = this.files[0].size;
                var size = fileSize / 1024 / 1024;
                if (size > 5) {
                    alert("附件不能大于5M,请将文件压缩后重新上传！");
                    this.value = "";
                    return false;
                } else {
                    $("#file_name").val($("#file").val()); //将 #file 的值赋给 #file_name
                }
            });
            $("form").submit(function () {
                if ($("#file").val() == "" || $("#file").val() == null) {
                    alert("未选择文件");
                    return false;
                }
            });
        });
    </script>
</body>

</html>
